package com.lg.customRxJava;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import java.util.concurrent.Callable;




public final class AndroidSchedulers     {
//
//    private static final class MainHolder {
//    static final Scheduler DEFAULT
//            = new HandlerScheduler(new Handler(Looper.getMainLooper()), true);
//}
//
//    private static final Scheduler MAIN_THREAD =
//            initMainThreadScheduler(() -> MainHolder.DEFAULT);
//
//
//    public static Scheduler mainThread() {
//        return onMainThreadScheduler(MAIN_THREAD);
//    }
//
//    /**
//     * A {@link io.reactivex.rxjava3.core.Scheduler} which executes actions on {@code looper}.
//     * <p>
//     * The returned scheduler will post asynchronous messages to the looper by default.
//     *
//     * @see #from(Looper, boolean)
//     */
//    public static Scheduler from(Looper looper) {
//        return from(looper, true);
//    }
//
//
//    @SuppressLint("NewApi") // Checking for an @hide API.
//    public static Scheduler from(Looper looper, boolean async) {
//        if (looper == null) throw new NullPointerException("looper == null");
//
//        // Below code exists in androidx-core as well, but is left here rather than include an
//        // entire extra dependency.
//        // https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat?hl=en#setAsynchronous(android.os.Message,%20kotlin.Boolean)
//        if (Build.VERSION.SDK_INT < 16) {
//            async = false;
//        } else if (async && Build.VERSION.SDK_INT < 22) {
//            // Confirm that the method is available on this API level despite being @hide.
//            Message message = Message.obtain();
//            try {
//                message.setAsynchronous(true);
//            } catch (NoSuchMethodError e) {
//                async = false;
//            }
//            message.recycle();
//        }
//        return new HandlerScheduler(new Handler(looper), async);
//    }
//
//    private AndroidSchedulers() {
//        throw new AssertionError("No instances.");
//    }
//
//    public static Scheduler initMainThreadScheduler(Callable<Scheduler> scheduler) {
//        if (scheduler == null) {
//            throw new NullPointerException("scheduler == null");
//        }
//        Function<Callable<Scheduler>, Scheduler> f = onInitMainThreadHandler;
//        if (f == null) {
//            return callRequireNonNull(scheduler);
//        }
//        return applyRequireNonNull(f, scheduler);
//    }
//
//    static Scheduler callRequireNonNull(Callable<Scheduler> s) {
//        try {
//            Scheduler scheduler = s.call();
//            if (scheduler == null) {
//                throw new NullPointerException("Scheduler Callable returned null");
//            }
//            return scheduler;
//        } catch (Throwable ex) {
//
//            //throw null
//        }
//    }
//
//    static Scheduler applyRequireNonNull(Function<Callable<Scheduler>, Scheduler> f, Callable<Scheduler> s) {
//       Scheduler scheduler = apply(f,s);
//        if (scheduler == null) {
//            throw new NullPointerException("Scheduler Callable returned null");
//        }
//        return scheduler;
//    }
//
//    static <T, R> R apply(Function<T, R> f, T t) {
//        try {
//            return f.apply(t);
//        } catch (Throwable ex) {
//            //throw Exceptions.propagate(ex);
//        }
//    }

}
